import type {ShallowRef} from 'vue';
import {onMounted} from 'vue';
import {throttle,operateDom} from '../../../util';

export default function(
	expandDom:ShallowRef<HTMLElement>,
	shrinkDom:ShallowRef<HTMLElement>,
	getSizeObject:() => void,
	time:number|false,
):() => void{
	const callback=operateDom(() => {
		getSizeObject();
		const expand=expandDom.value;
		const shrink=shrinkDom.value;
		expand.scrollLeft=shrink.scrollLeft=1e8;
		expand.scrollTop=shrink.scrollTop=1e8;
	});
	const emitEvent=time===false?callback:throttle(callback,time||undefined);
	onMounted(emitEvent);
	return emitEvent;
}